package com.lianboke.link.ad.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.lianboke.link.ad.utils.DeviceUtils;
import com.lianboke.link.ad.utils.KLog;

/**
 * 网络数据变更监控器
 * Created by admin on 2017/11/7.
 */

public class NetBroadcastReceiver extends BroadcastReceiver {

    private static String NET_CHANGE_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
    @Override
    public void onReceive(Context context, Intent intent) {
        try {
            KLog.e("device_tag","-----net work type  action-------:"+intent.getAction());
            if (intent != null && NET_CHANGE_ACTION.equals(intent.getAction())) {
                String strNetType = DeviceUtils.getDeviceAc();
                //==========
                Intent intentNet = new Intent();
                intentNet.setAction("com.sarnasea.interprocess.MYBROAD_ACTION");
                intentNet.putExtra("data", strNetType);
                context.sendBroadcast(intentNet);
            }
        }catch (Exception e){
            KLog.e("device_tag","-----net work type  action----Exception---:"+e.getMessage());
        }

    }
}
